package day_2022_12_to_3.year2023;

/**
 * @author haomin
 * @date 2023/01/09 22:58
 **/
public class Day1_9_Num1806 {
    class Solution {
        public int reinitializePermutation(int n) {
            if (n == 2) {
                return 1;
            }
            int step = 1, pow2 = 2;
            while (pow2 != 1) {
                step++;
                pow2 = pow2 * 2 % (n - 1);
            }
            return step;
        }
    }
}